package com.matt.sooncleaner.arch

import android.content.res.Resources
import android.util.TypedValue

val Float.dp
    get() = with(
        TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_DIP,
            this,
            Resources.getSystem().displayMetrics
        )
    ) {
        this
    }

val Int.dp
    get() = with(
        TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_DIP,
            this.toFloat(),
            Resources.getSystem().displayMetrics
        )
    ) {
        val f = this
        (if (f >= 0) f + 0.5f else f - 0.5f).toInt()
    }
